package com.wenjie.original.entity;

import com.mybatisflex.annotation.*;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import com.wenjie.original.flex_config.typehandler.SetLongTypeHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Arrays;
import java.util.Set;


@Data
@Table("scan_record")
@ApiModel("打包记录")
public class ScanRecord extends BaseEntity {

    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @ApiModelProperty("打包记录主键")
    private Long scanRecordId;

    @ApiModelProperty("上层打包计划")
    private Long parentScanRecordId;

    @ApiModelProperty("订单主键")
    private Long orderId;

    @ApiModelProperty("包装主键")
    private Long boxId;

    @ApiModelProperty("商品主键")
    private Long skuId;

    @ApiModelProperty("打包计划主键")
    private Long orderBoxId;

    @ApiModelProperty("编号")
    private String code;

    @ApiModelProperty("订单名称")
    private String orderName;

    @ApiModelProperty("订单的标识")
    private String orderKey;


    @ApiModelProperty("商品品名")
    private String skuName;

    @ApiModelProperty("商品条形码")
    private String skuBarCode;


    @ApiModelProperty("包装名称")
    private String boxName;

    @ApiModelProperty("条形码")
    private String boxBarCode;

    @ApiModelProperty("重量范围-最低(kg)")
    private String orderBoxByBoxLowWeight;

    @ApiModelProperty("重量范围-最高(kg)")
    private String orderBoxByBoxHighWeight;

    @ApiModelProperty("打包数据的集合")
    @Column(typeHandler = SetLongTypeHandler.class)
    private Set<Long> scanGroups;

    @ApiModelProperty("扫码类型")
    private SCAN_TYPE scanType;

    @ApiModelProperty("包装的顺序")
    private Integer orderBoxBySequence;

    @ApiModelProperty("实际的包装数量")
    private Integer scanNum;

    @ApiModelProperty("实际的包装重量")
    private String scanWeight;

    @ApiModelProperty("订单信息")
    private String orderInfo;

    @ApiModelProperty("商品信息")
    private String skuInfo;

    @ApiModelProperty("箱子信息")
    private String boxInfo;

    @ApiModelProperty("包装计划信息")
    private String orderBoxInfo;


    @Getter
    @AllArgsConstructor
    public enum SCAN_TYPE implements IEnum<Integer> {
        arg1(1, "商品打包"), arg2(2, "包装打包");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static SCAN_TYPE getBycode(Integer code) {
            return Arrays.stream(SCAN_TYPE.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }


}